// PotatoSoft.FundusReconstruction.Test.cpp : main project file.

#include "stdafx.h"
// include open cv 

using namespace System;
using namespace System::Collections::Generic;


public ref class Fr
{
	static array<unsigned char,1>^ FundusReconstruction(List<array<unsigned char,1>^>^ bscansList,
		int width,int height,int min,int max)
	{
		int size=bscansList->Count*width;
		array<unsigned char,1>^ fundusReconstruction=gcnew array<unsigned char,1>(size);
			
		int count=0;

		// for every bscan
		for each(array<unsigned char,1>^ bscan in bscansList)
		{	
			// for every ascan i bscan
			for (int offset=0; offset<width; offset++)
			{
				int sum=0;
				
				// sum ascan
				for (int i=min; i<max; i++)
					sum+=bscan[i*width+offset];

				// make average
				double avgDouble=(double)sum/(max-min);

				unsigned char avg=(unsigned char)avgDouble;
					
				fundusReconstruction[count++]=avg;
			}
		}

		return fundusReconstruction;
	}
};

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Hello World");
    return 0;
}
